package com.yh.controller.admin;

import com.yh.service.UserService;
import com.yh.utils.Constants;
import com.yh.vo.CustomPageAndNavigate;
import com.yh.vo.ResponseVO;
import com.yh.vo.UserVO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yuhuan
 * @date 2022/01/13
 */
@RestController
@RequestMapping("/admin/user")
public class UserManageController {
    @DubboReference(check = false)
    private UserService userService;

    /**
     * 查询所有的用户并分页
     * 服务地址：http://localhost:8081/admin/user/all
     */
    @RequestMapping("all")
    public ResponseVO findUserAll(Integer pageNum, Integer pageSize) {
        CustomPageAndNavigate<UserVO> userAll = userService.findUserAll(pageNum, pageSize);
        return !ObjectUtils.isEmpty(userAll.getList()) ? ResponseVO.buildSuccessInstance(userAll) :
                ResponseVO.buildSuccessInstance(Constants.ResponseDataState.NULL_RESULT);
    }
}
